<template>
  <div class="demo-title">action-sheet/demo3</div>
  <div class="demo">
    <Form ref="formRef" :label-width="70" :data="formData" :rules="rules">
      <FormItem label="文本" field="input">
        <Input v-model="formData.input" placeholder="请输入包含ssc的英文" />
      </FormItem>
    </Form>
    <div class="submit" @click="submit()">提交</div>
  </div>
</template>

<script lang="ts" setup>
  import { reactive, ref } from 'vue'
  import { Form, FormItem } from '@sscd-mobile/form'
  import Input from '@sscd-mobile/input'
  /** 表单 */
  const formRef = ref()
  /** 表单数据 */
  const formData = reactive({
    input: ''
  })
  /** 校验规则 */
  const rules = [
    { field: 'input', required: true, type: 'reg', reg: /^(?=.*ssc)[A-Za-z]+$/i, regMsg: '请输入包含ssc的英文' }
  ]
  /**
   * 表单提交
   */
  const submit = () => {
    console.log('submit: ', formRef.value.valid())
  }
</script>

<style scoped>
  .demo {
    padding: 16px 16px 0;
    background: #fff;
  }
  .submit {
    height: 30px;
    line-height: 30px;
    text-align: center;
    background: var(--sscd-primary-color);
    color: #fff;
  }
</style>
